package test.work.vo;

import java.io.Serializable;

public class Student implements Serializable, Comparable<Student>{
	private int stdNum;//학번
	private String stdName;//이름
	private int kor;//국어점수
	private int eng;//영어점수
	private int math;//수학점수
	
	//학번과 이름만을 받는 생성자
	public Student(int stdNum, String stdName) {
		this.stdNum = stdNum;
		this.stdName = stdName;
	}

	//모든 정보를 받는 생성자
	public Student(int stdNum, String stdName, int kor, int eng, int math) {
		this.stdNum = stdNum;
		this.stdName = stdName;
		this.kor = kor;
		this.eng = eng;
		this.math = math;
	}
	
	//Getter and Setter
	public int getStdNum() {
		return stdNum;
	}

	public void setStdNum(int stdNum) {
		this.stdNum = stdNum;
	}

	public String getStdName() {
		return stdName;
	}

	public void setStdName(String stdName) {
		this.stdName = stdName;
	}

	public int getKor() {
		return kor;
	}

	public void setKor(int kor) {
		this.kor = kor;
	}

	public int getEng() {
		return eng;
	}

	public void setEng(int eng) {
		this.eng = eng;
	}

	public int getMath() {
		return math;
	}

	public void setMath(int math) {
		this.math = math;
	}
	
	//총점
	public int sumScore(){
		return kor+eng+math;
	}
	
	//평균
	public double avgScore(){
		return sumScore()/3.0;
	}

	//toString override
	@Override
	public String toString() {
		return String
				.format("%3s%5s%3s%3s%3s%3s%6.2f",
						stdNum, stdName, kor, eng, math, sumScore(), avgScore());
	}
	

	@Override
	public boolean equals(Object obj) {
		boolean result = false;
		if(obj instanceof Student){
			Student temp = (Student)obj;
			result= stdNum==temp.stdNum&&stdName.equals(temp.stdName);
		}
		return result;
	}

	@Override
	public int compareTo(Student o) {
		return stdNum-o.stdNum;
	}	
}
